package com.csdj.t309.geamtest.controller;


import com.csdj.t309.geamtest.common.CacheConstant;
import com.csdj.t309.geamtest.common.WebResult;
import com.csdj.t309.geamtest.common.WebResultMsgCode;
import com.csdj.t309.geamtest.entity.Blindbox;
import com.csdj.t309.geamtest.service.BlindboxService;
import com.csdj.t309.geamtest.service.RedisService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 田港
 * @since 2022-01-20
 */
@RestController
@RequestMapping("/blindbox")
public class BlindboxController {
    @Resource
    private BlindboxService blindboxService;
    @Resource
    private RedisService redisService;

    @GetMapping("/selbox")
    public WebResult selBox(@RequestParam(value = "jsId" , required = true) Integer jsId,
                            HttpServletRequest request){
        List<Integer> list = blindboxService.selbox(jsId,redisService.getObject(CacheConstant.HEADER_UID+request.getHeader(CacheConstant.HEADER_UID)));
        return new WebResult(WebResultMsgCode.SUCCESS).putData("list",list);
    }
}
